package com.seckill.goods.pojo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 * 商品表
 * </p>
 * @author 作者
 * @since 2022-03-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_sku")
////@ApiModel(value="Sku", description="商品表")
public class Sku implements Serializable {


    ////@ApiModelProperty(value = "商品id")
    @TableId("id")
    private String id;

    ////@ApiModelProperty(value = "SKU名称")
    @TableField("name")
    private String name;

    ////@ApiModelProperty(value = "价格（分）")
    @TableField("price")
    private Integer price;

    ////@ApiModelProperty(value = "单位，分")
    @TableField("seckill_price")
    private Integer seckillPrice;

    ////@ApiModelProperty(value = "库存数量")
    @TableField("num")
    private Integer num;

    ////@ApiModelProperty(value = "库存预警数量")
    @TableField("alert_num")
    private Integer alertNum;

    ////@ApiModelProperty(value = "商品图片")
    @TableField("image")
    private String image;

    ////@ApiModelProperty(value = "商品图片列表")
    @TableField("images")
    private String images;

    ////@ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    ////@ApiModelProperty(value = "更新时间")

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    ////@ApiModelProperty(value = "SPUID")
    @TableField("spu_id")
    private String spuId;

    ////@ApiModelProperty(value = "类目ID")
    @TableField("category1_id")
    private Integer category1Id;

    @TableField("category2_id")
    private Integer category2Id;

    @TableField("category3_id")
    private Integer category3Id;

    @TableField("category1_name")
    private String category1Name;

    @TableField("category2_name")
    private String category2Name;

    ////@ApiModelProperty(value = "类目名称")
    @TableField("category3_name")
    private String category3Name;

    @TableField("brand_id")
    private Integer brandId;

    ////@ApiModelProperty(value = "品牌名称")
    @TableField("brand_name")
    private String brandName;

    ////@ApiModelProperty(value = "规格")
    @TableField("spec")
    private String spec;

    ////@ApiModelProperty(value = "销量")
    @TableField("sale_num")
    private Integer saleNum;

    ////@ApiModelProperty(value = "评论数")
    @TableField("comment_num")
    private Integer commentNum;

    ////@ApiModelProperty(value = "秒杀结束时间")
    @TableField("seckill_end")
    private Date seckillEnd;

    ////@ApiModelProperty(value = "秒杀开始时间")
    @TableField("seckill_begin")
    private Date seckillBegin;

    ////@ApiModelProperty(value = "商品状态 1普通商品，2参与秒杀")
    @TableField("status")
    private Integer status;

    ////@ApiModelProperty(value = "是否锁定，1：未锁定，2：锁定")
    @TableField("islock")
    private Integer islock;

    ////@ApiModelProperty(value = "秒杀数量")
    @TableField("seckill_num")
    private Integer seckillNum;

    ////@ApiModelProperty(value = "审核状态：1已审核，2未审核")
    @TableField("audit")
    private Integer audit;

    ////@ApiModelProperty(value = "限购数量")
    @TableField("count")
    private Integer count;

    ////@ApiModelProperty(value = "是否删除：1 否，2 删除")
    @TableField("isdel")
    private Integer isdel;

    @TableField(exist = false)
    private String bgtime;

    //静态页地址
    @TableField("html_url")
    private String htmlUrl;

    public String getBgtime() {
        if(seckillBegin!=null && bgtime==null){
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHH");
            return simpleDateFormat.format(seckillBegin);
        }
        return bgtime;
    }
}
